from django.db import models


# Create your models here.


# 存储轮播图的模型
class Banner(models.Model):
    """
    这个模型包含的字段

    verbose_name表示在后台站点对应的字段名字
    """

    # 字段
    title = models.CharField(max_length=500, verbose_name="广告标题")  # 标题
    img_path = models.ImageField(upload_to=r'banner', null=True, blank=True, verbose_name="广告图片")
    img_link = models.CharField(max_length=500, verbose_name="广告链接")
    remark = models.TextField(verbose_name="备注信息")
    is_show = models.BooleanField(default=False, verbose_name="是否展示图像")
    is_delete = models.BooleanField(default=False, verbose_name="是否删除图像")
    orders = models.IntegerField(default=1, verbose_name="排序")

    # create_time = models.DateField()
    # update_time = models.DateField()

    # 表信息
    class Meta:
        # 表明
        db_table = "ly_banner"
        verbose_name = "轮播广告图"
        verbose_name_plural = verbose_name

    # 自定义方法
    def __str__(self):
        return self.title
